using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using System.Reflection;
using System.Xml.Serialization;
using System.Xml;

namespace Hutchinson.CustomField.ItemID
{
    class HutItemIDEventHandler: SPItemEventReceiver
    {
        public override void ItemAdded(SPItemEventProperties properties)
        {
            bool needUpdate = false;
            base.ItemAdded(properties);

            foreach (SPField  oField in properties.ListItem.Fields)
	        {
                if (oField is HutItemID)
                {
                    properties.ListItem[oField.Id] = properties.ListItem["ID"];
                    needUpdate = true;
                }
	        }

            if (needUpdate)
                properties.ListItem.Update();
        }

    }
}
